package com.nari.ncps.screen.service.impl.ne;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nari.ncps.screen.entity.ne.NeWindResource;
import com.nari.ncps.screen.mapper.ne.NeWindResourceMapper;
import com.nari.ncps.screen.service.ne.NeWindResourceService;
import com.nari.ncps.screen.vo.ne.WindResourceVO;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * <p>
 * 新能源实时数据表 服务实现类
 * </p>
 *
 * @author xuesong
 * @since 2025-08-23
 */
@Service
public class NeWindResourceServiceImpl extends ServiceImpl<NeWindResourceMapper, NeWindResource> implements NeWindResourceService {

    /**
     * 风电资源
     *
     * @param orgCode
     * @return
     */
    @Override
    public WindResourceVO getWindResource(String orgCode) {
        if (orgCode == null) {
            orgCode = "134058";
        }
        LambdaQueryWrapper<NeWindResource> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(NeWindResource::getDelFlag, 0).eq(NeWindResource::getOrgCode, orgCode);
        NeWindResource nePopupBasic = this.getOne(queryWrapper);
        WindResourceVO vo = new WindResourceVO();
        if (nePopupBasic != null) {
            vo.setAverageWindSpeed(nePopupBasic.getAvgWindSpeed());
            vo.setCurrentWindSpeed(nePopupBasic.getCurrentWindSpeed());
        } else {
            vo.setCurrentWindSpeed(BigDecimal.ZERO);
            vo.setAverageWindSpeed(BigDecimal.ZERO);
        }
        return vo;
    }


}
